{template 'include/header'}
<script type="text/javascript">
        //调用微信JS api 支付
        function jsApiCall() {
            WeixinJSBridge.invoke(
                    'getBrandWCPayRequest',
            <?php echo $jsApiParameters; ?>,
            function (res) {
               // WeixinJSBridge.log(res.err_msg);
                if(res.err_msg == "get_brand_wcpay_request:ok" ) {
					location.href = '{php echo $this->createMobileUrl('pay',array('fund_id'=>$fund_id , 'fund_value'=>$fund_value, 'order_num'=>$out_trade_no))}';
                } else{
                    alert(res.err_code+res.err_desc+res.err_msg);
                }
            });

   //          wx.chooseWXPay({
			// 	<?php echo $jsApiParameters; ?>,
			// 	success: function (res) {
			// 		if(res.err_msg == "get_brand_wcpay_request:ok" ) {
			// 			location.href = '{php echo $this->createMobileUrl('pay',array('fund_id'=>$fund_id , 'fund_value'=>$fund_value, 'order_num'=>$out_trade_no))}';
	  //               } else{
	  //                   alert(res.err_code+res.err_desc+res.err_msg);
	  //               }
			// 	}
			// });
        }

        function callpay() {
            if (typeof WeixinJSBridge == "undefined") {
                if (document.addEventListener) {
                    document.addEventListener('WeixinJSBridgeReady', jsApiCall, false);
                } else if (document.attachEvent) {
                    document.attachEvent('WeixinJSBridgeReady', jsApiCall);
                    document.attachEvent('onWeixinJSBridgeReady', jsApiCall);
                }
            } else {
                jsApiCall();
            }
        }

    </script>
<div class="container container-fill">
<style>
	body{background:#EEE;}
	.container-fill{padding:.5em;}
	h4{margin:15px 0;}
	h5{color:#555;}
	h4:first-of-type{margin-top:10px;}
	.panel{padding:.5em; margin-bottom:10px;}
	.nav.nav-tabs{margin-bottom:.8em;}
	.alert .form-group{margin-bottom:0;}
	label.form-group{display:block;}
	label.form-group{font-weight:normal; overflow:hidden; border-top:1px #DDD solid; padding-top:10px;padding-bottom:0;margin-bottom:0 }
	label.form-group .col-xs-2{margin-top:0px;}
	label.form-group input[name="type"]{opacity:0; width:0;}
	#wq_card .form-group{border-top:none;border-bottom:1px solid #ccc;}
	#wq_card .form-group .col-xs-2{margin-top:15px;}
</style>

<h4>捐款信息</h4>
<div class="panel">
	<div class="clearfix" style="padding-top:10px;">
		<p>机构名称 :<span class="pull-right">{$set['gy_name']}</span></p>
		<p>支付金额 :<span class="pull-right">￥{$fund_value} 元</span></p>
	</div>
</div>

<h4>支付方式</h4>
<ul class="nav nav-tabs" role="tablist" style="margin-bottom:0;">
	<li class="active" data-id="direct"><a href="#direct" role="tab" data-toggle="tab" style="border-left:0;">直接到账</a></li>
</ul>
<div class="panel" style="border-top-left-radius:0; border-top-right-radius:0;">
	<div class="tab-content">
		<div class="tab-pane animated active fadeInLeft" id="direct">
			<div class="clearfix">
				<label class="form-group">
					<div class="col-xs-2">
						<input type="radio" name="type" value="wechat">
						<i class="fa fa-check-circle fa-lg text-muted"></i>
					</div>
					<div class="col-xs-10">
						使用微信支付
						<div class="help-block">每笔最高五千元, 每日限额五千元</div>
					</div>
				</label>
			</div>
		</div>
	</div>
</div>
<input type="hidden" name="token" value="{$_W['token']}" />
<div class="pay1246-btn" id="wechat-panel">
		<button class="btn btn-warning btn-block btn-lg" disabled="disabled" type="submit" id="wBtn" value="wechat" style="background:#fe6903; border-color:#fe6903; color:#fff;
">微信支付(必须使用微信内置浏览器)</button>
</div>
<script type="text/javascript">
	document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
		$('#wBtn').removeAttr('disabled');
		$('#wBtn').html('微信支付');
	});
	$("#wBtn").click(function(){ 
		callpay();
	});
</script>
</div>
<script type="text/javascript">
	function tomedia(src) {
		if(typeof src != 'string')
			return '';
		if(src.indexOf('http://') == 0 || src.indexOf('https://') == 0) {
			return src;
		} else if(src.indexOf('../addons') == 0 || src.indexOf('../attachment') == 0) {
			src=src.substr(3);
			return window.sysinfo.siteroot + src;
		} else if(src.indexOf('./resource') == 0) {
			src=src.substr(2);
			return window.sysinfo.siteroot + 'app/' + src;
		} else if(src.indexOf('images/') == 0) {
			return window.sysinfo.attachurl+ src;
		}
	}
</script>
	
</body>
</html>